package control;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;

import animation.Animator;


import challengeGUI.CharacterSearchGUI;

/**
 * Yuliy Khorolinskyy
 * SE Projekt 2011
 *
 * Reaktionsspiel
 * SimpleTimer.java
 *
 */

/**
 * @author y.khorolinskyy
 *
 */
public class SimpleTimer extends Timer{
	//Not thread safe
	private static boolean timerTaskComplete = false;
	

	public SimpleTimer(int delay, ActionListener listener) {
		super(delay, listener);
	}
	
	@Deprecated
	public static void pause(int millis){
		try {
			for(int i = 0; i<millis/20; i++) {
				Thread.sleep(20);
			}
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block jaja
			//e.printStackTrace();
		}
//		timerTaskComplete = false;
//		Timer t = new Timer(millis, new ActionListener(){
//			@Override
//			public void actionPerformed(ActionEvent e) {
//			 SimpleTimer.this.timerTaskComplete = true;	
//			}
//			
//		});
//		
//		
//		t.start();
//		while(!timerTaskComplete){}
//		t.stop();
	}
	
	public static void pause(int millis, ActionListener a) {
//		try {
//			for(int i = 0; i<millis/20; i++) {
//				ani.nextFrame();
//				Thread.sleep(20);
//			}
//		} catch (InterruptedException e) {
//			// Nix
//		}
		Timer tmp = new Timer(millis, a);
		tmp.setRepeats(false);
		tmp.start();
	}

	

	/**
	 * Simple time stamp method
	 * @return The current time (non lacation dependant) with millisecond precision.
	 */
	 public static long getTimeStamp(){
		  return System.currentTimeMillis();
		 
	 }
}
